.TH std::complex::operator= 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::complex::operator= \- std::complex::operator=

.SH Synopsis
   All specializations
   complex& operator=( const complex& cx );             (until
                                                        C++20)
   constexpr complex& operator=( const complex&         (since
   cx );                                                C++20)
   template< class X >                                          (until
   complex& operator=( const std::complex<X>&                   C++20)
   cx );
   template< class X >                                          (since
   constexpr complex& operator=( const                          C++20)
   std::complex<X>& cx );
   Primary template complex<T>
   complex& operator=( const T& x );            \fB(1)\fP                     (until
                                                                        C++20)
   constexpr complex& operator=( const T& x );      \fB(2)\fP                 (since
                                                                        C++20)
   Specializations for standard floating-point
   types complex<F> (until C++23)                       \fB(3)\fP
   complex& operator=( F x );                                                   (until
                                                                                C++20)
                                                                \fB(3)\fP             (since
   constexpr complex& operator=( F x );                                         C++20)
                                                                                (until
                                                                                C++23)

   Assigns new values to the contents.

   1,2) Assigns cx.real() and cx.imag() to the real and the imaginary parts of the
   complex number respectively.
   The copy assignment operator \fB(1)\fP is trivial when T is a floating-point type.
   (since C++23)
   3) Assigns x to the real part of the complex number. Imaginary part is set to zero.

.SH Parameters

   x  - value to assign
   cx - complex value to assign

.SH Return value

   *this

.SH Notes

   The copy assignment operator is required to be trivial since C++23, but
   implementations generally make it trivial in all modes.

   Defect reports

   The following behavior-changing defect reports were applied retroactively to
   previously published C++ standards.

      DR    Applied to            Behavior as published            Correct behavior
   LWG 3935 C++98      the description of overload \fB(2)\fP was missing added

.SH See also

   constructor   constructs a complex number
                 \fI(public member function)\fP
   operator""if
   operator""i   a std::complex literal representing purely imaginary number
   operator""il  \fI(function)\fP
   \fI(C++14)\fP
